<template>
  <div>
    <van-swipe-cell v-for="v in chatList" :key="v.recordId">
      <van-cell
        :border="false"
        :title="v.nickName"
        :value="v.lastContent"
        :icon="v.userHeadPic"
        @click="
          $router.push({
            path: '/chat/' + v.recordId,
            query: {
              nickname: v.nickName,
              userId: v.userId
            }
          })
        "
      />
      <template #right>
        <van-button square type="danger" text="结束问诊" @click="deeteList(v.recordId)" />
      </template>
    </van-swipe-cell>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { request } from '../../utils/request'

interface ChatItemState {
  doctorHeadPic: string
  inquiryTime: 1718176118000
  jiGuangPwd: string
  nickName: string
  recordId: 9848
  status: 1
  userHeadPic: string
  userId: 522
  userName: string
  lastContent: string
}
const deeteList = async (recordId: number) => {
  const resp = await request({
    url: '/health/doctor/inquiry/verify/v1/endInquiry',
    method: 'put',
    params: { recordId }
  })

  _getList()
}

const chatList = ref<ChatItemState[]>([])

const _getList = async () => {
  const resp = await request({
    url: '/health/doctor/inquiry/verify/v1/findInquiryRecordList'
  })

  console.log(resp.data)
  chatList.value = resp.data.result
}

_getList()
</script>
